﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using daSyntaxAnalyser.SyntaxTree;
using CQLQueries.Analyzers;

namespace CQLQueries.SyntaxTree
{
    public class Term2Node
    {
        public object NodeTree;
        public object ValueDown;
        public object ValueUp;

        public TermNode Term;
        public CQLTokens Op;

        public Term2Node(CQLTokens Op1)
        {
            Op = Op1;
        }

        public void Visit()
        {
            Term.NodeTree = NodeTree;
            Term.Visit();
            switch (Op)
            { 
                case CQLTokens.Mul:
                    ValueUp = Convert.ToDouble(ValueDown) * Convert.ToDouble(Term.ValueUp);
                    break;
                case CQLTokens.Div:
                    ValueUp = Convert.ToDouble(ValueDown) / Convert.ToDouble(Term.ValueUp);
                    break;
                case CQLTokens.Mod:
                    ValueUp = Convert.ToDouble(ValueDown) % Convert.ToDouble(Term.ValueUp);
                    break;
            }
        }
    }
}
